﻿using ConfExpert.Forms.Base;
using DevTeam;
using System;
using System.ComponentModel;




namespace ConfExpert.Forms.Aksesuar
{
    public partial class AksesuarDonem : XForm
    {
        public AksesuarDonem()
        {
            InitializeComponent();
        }

        private void AksesuarDonem_Load(object sender, EventArgs e)
        {
            gvDonem.Init("GetAksesuarDonem");

            gvDonem.MakeReadOnly("Yil", "Donem");
            gvDonem.MakeColumnInvisible("AksesuarDonemId", "InsertedOn");

            GridManager gm = GridManager.GetManager(gvDonem);
            gm.Pasting += gm_Pasting;

            bbiDonemEkle.ItemClick += bbiDonemEkle_ItemClick;
            gvDonem.ShowingEditor += gvDonem_ShowingEditor;
        }

        void gvDonem_ShowingEditor(object sender, CancelEventArgs e)
        {
            string BitisTarihi = gvDonem.GetFocusedRowCellValue( "BitisTarihi").ToString();
            e.Cancel = !(BitisTarihi == "" && (gvDonem.FocusedColumn.FieldName == "Yil" || gvDonem.FocusedColumn.FieldName == "Donem")); 
        }

        void gm_Pasting(int rowHandle, DevExpress.XtraGrid.Columns.GridColumn column, object val, CancelEventArgs ce)
        {
            string BitisTarihi = gvDonem.GetRowCellValue(rowHandle, "BitisTarihi").ToString();
            ce.Cancel = !(BitisTarihi == "" && (column.FieldName == "Yil" || column.FieldName == "Donem")); 
        }

        void bbiDonemEkle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            throw new NotImplementedException();
        }
    }
}
